﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FazaDemo.Data;
using FazaDemo.QL.AbstractQueryModel;
using FazaDemo.BL.Domain;

namespace FazaDemo.QueryModel
{
    public class HouseRepository : IQueryRepository<object, House>
    {
        public House Get(object context)
        {
            return null;
        }

        public IList<House> Get()
        {
            using (var dbContext = new FazaEntities1())
            {
                var houses = dbContext.Set<TB_HOUSE>().Where(h => h.HOUSE == "35").ToList();
                return houses.Select(h => new House
                {
                    Id = h.ID, 
                    StreetId = h.STREET_ID, 
                    HouseNumber = h.HOUSE, 
                    Korp = h.KORP, 
                    Created = h.CREATED, 
                    Updated = h.UPDATED
                }
                ).ToList();
            }
        }
    }
}
